package com.xuehu.loadBalancer;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author guoweia@cslc.com.cn
 * @createTime 2020/11/30 11:07
 * @description 自定义ribbon负载均衡策略,默认是轮询，注意包名，不能在@ComponentScan所扫描的包名内
 */
@Configuration
public class RibbonRule {

    /**
     * 随机策略
     * @return
     */
    @Bean
    public IRule randomRule() {
        return new RandomRule();
    }
}
